package cn.keniykey.mc.viewlibrary.reflection;

import java.lang.reflect.Field;

import javax.annotation.Nullable;

/**
 * 反射动态类参数
 */
public class ReflectionDynamicField {
	private final Field field;
	private final Object obj;
	
	public ReflectionDynamicField(Field field,Object obj) {
		this.field = field; this.obj = obj;
	}
	
    public void set(@Nullable final Object param) {
        try {
            this.field.set(this.obj, param);
        }catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
    @Nullable
    public Object get() {
        try {
            return this.field.get(this.obj);
        }catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
}